package com.vcc.service.service;

import com.mybatisflex.core.service.IService;
import com.vcc.data.entity.Currency;
import com.vcc.data.entity.Wallet;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


public interface WalletService extends IService<Wallet> {

    List<Wallet> listByUserId(Long userId);

    List<Wallet> listByUserIds(List<Long> userIds);

    Boolean init(List<Currency> currencies, Long userId);

    Boolean init(Long currencyId, String currencyCode, List<Long> userIds);

    Wallet getNotRateWalletById(Long walletId);

    Wallet getByUserIdAndCurrencyId(Long userId, Long currencyId);

    Wallet getByUserIdAndCurrencyCode(Long userId, String currencyCode);

    Wallet getByUserIdAndCurrencyCodeNoRate(Long userId, String currencyCode);

    Boolean openCard(
            Long userId,
            Long operatorUserId,
            String currencyCode,
            String orderId,
            Long cardTypeId,
            String channelName,
            BigDecimal amount,
            String remark,
            String dateSource
    );

    Boolean cardRecharge(
            Long userId,
            Long operatorUserId,
            String currencyCode,
            String orderId,
            Long cardTypeId,
            String cardNumber,
            Long userCardId,
            String channelName,
            BigDecimal amount,
            String remark,
            String dateSource
    );

    Boolean systemCardRecharge(
            Long userId,
            Long operatorUserId,
            String currencyCode,
            String orderId,
            Long cardTypeId,
            String cardNumber,
            Long userCardId,
            String channelName,
            BigDecimal amount,
            String remark,
            String dateSource
    );

    Boolean cardWithdraw(
            Long userId,
            Long operatorUserId,
            String currencyCode,
            String orderId,
            Long cardTypeId,
            String cardNumber,
            Long userCardId,
            String channelName,
            BigDecimal amount,
            String remark,
            String dateSource
    );

    BigDecimal getUsableQuotaByUserIdAndCurrencyId(Long userId, Long currencyId);

    BigDecimal getUsableQuotaByUserIdAndCurrencyCode(Long userId, String currencyCode);

    Boolean updateRateById(Long id, BigDecimal rate);

    /**
     * 修改额度
     *
     * @param flag       1 增 2 减 3 乘 4 除
     * @param useFlag    0 不动 1 账户充值 2 消费 3 销卡 4 充值失败
     * @param otExStatus true  忽略减少钱时为0的错误   false  不忽略
     */
    BigDecimal updateUsableQuotaById(Long id, BigDecimal amount, Integer flag, Integer useFlag, Boolean otExStatus);

    /**
     * 修改额度
     *
     * @param useFlag    0 不动 1 账户充值 2 消费 3 销卡 4 充值失败
     * @param otExStatus true  忽略减少钱时为0的错误   false  不忽略
     */
    BigDecimal addUsableQuotaById(Long id, BigDecimal amount, Integer useFlag, Boolean otExStatus);

    /**
     * 修改额度
     *
     * @param useFlag    0 不动 1 账户充值 2 消费 3 销卡 4 充值失败
     * @param otExStatus true  忽略减少钱时为0的错误   false  不忽略
     */
    BigDecimal subtractUsableQuotaById(Long id, BigDecimal amount, Integer useFlag, Boolean otExStatus);

    /**
     * 修改额度
     *
     * @param flag       1 增 2 减 3 乘 4 除
     * @param useFlag    0 不动 1 账户充值 2 消费 3 销卡 4 充值失败
     * @param otExStatus true  忽略减少钱时为0的错误   false  不忽略
     */
    BigDecimal updateUsableQuotaByUserIdAndCurrencyId(Long userId, Long currencyId, BigDecimal amount, Integer flag, Integer useFlag, Boolean otExStatus);

    /**
     * 修改额度
     *
     * @param useFlag    0 不动 1 账户充值 2 消费 3 销卡 4 充值失败
     * @param otExStatus true  忽略减少钱时为0的错误   false  不忽略
     */
    BigDecimal addUsableQuotaByUserIdAndCurrencyId(Long userId, Long currencyId, BigDecimal amount, Integer useFlag, Boolean otExStatus);

    /**
     * 修改额度
     *
     * @param useFlag    0 不动 1 账户充值 2 消费 3 销卡 4 充值失败
     * @param otExStatus true  忽略减少钱时为0的错误   false  不忽略
     */
    BigDecimal subtractUsableQuotaByUserIdAndCurrencyId(Long userId, Long currencyId, BigDecimal amount, Integer useFlag, Boolean otExStatus);


    Map<String, BigDecimal> summaryBalance();
}
